import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/res/assets_res.dart';
import 'package:xindong/routes/call/controller/xindong_call_controller.dart';
import 'package:xindong/routes/call/controller/xindong_call_view_ctr.dart';
import 'package:xindong/routes/call/dialog/xindong_call_action_button.dart';
import 'package:xindong/routes/call/view/xindong_call_footer_view.dart';
import 'package:xindong/routes/call/view/xindong_call_header_view.dart';
import 'package:xindong/routes/call/view/xindong_call_poor_view.dart';
import 'package:xindong/routes/call/view/xindong_call_timer_view.dart';
import 'package:xindong/utils/xindong_image_util.dart';

// 控件层 （点击隐藏/显示）
class XinDongCallControlView extends StatelessWidget {
  const XinDongCallControlView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final controller = Get.put(XinDongCallViewController());
    return GetBuilder<XinDongCallViewController>(
      builder: (controller) {
        return AnimatedOpacity(
          opacity: controller.viewControlOpacity,
          duration: const Duration(milliseconds: 500),
          child: Container(
            padding: EdgeInsets.only(top: statusBarHeight, bottom: bottomBarHeight),
            child: Stack(
              alignment: Alignment.center,
              children: [
                Column(
                  children: [
                    // 头部信息
                    const XinDongCallHeaderView(),

                    // 通话时长
                    const XinDongCallTimerView(),

                    Expanded(
                      child: GestureDetector(
                        behavior: HitTestBehavior.opaque, // 透明的也可以点击，点击事件不实现，传递给上层（视频层阻碍了点击事件）
                        child: Container(),
                      ),
                    ),
                    // 聊天框
                    // Container(
                    //   height: 200,
                    //   child: XinDongGroupChatListView(),
                    // ),
                    // 余额不足
                    const Padding(
                      padding: EdgeInsets.only(bottom: 20),
                      child: XinDongCallPoorView(),
                    ),

                    // 工具底栏
                    const XinDongCallFooterView(),

                    // 挂断按钮
                    Padding(
                      padding: EdgeInsets.only(bottom: 34 + bottomBarHeight),
                      child: XinDongCallActionButton(
                        size: 56,
                        icon: ImageUtil.asset(AssetsRes.BUTTON_HANGUP),
                        onPressed: () => XinDongCallController.to.hangup(),
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}
